# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models,api
from odoo.exceptions import ValidationError
import odoo.addons.decimal_precision as dp

class mrp_production(models.Model):
    _inherit = 'mrp.production'



    order_can_cancel = fields.Boolean(u'可取消',compute='_order_can_cancel')

    @api.depends('move_raw_ids','move_finished_ids')
    def _order_can_cancel(self):
        for production in self:
            production.order_can_cancel=True
            if production.state=='done' or production.state=='cancel':
                production.order_can_cancel = False
                return
            for raw in production.move_raw_ids:
                if raw.state=='done':
                    production.order_can_cancel = False
                    return
            for fini in production.move_finished_ids:
                if fini.state=='done':
                    production.order_can_cancel = False
                    return
